//worksheet.js   这里确定表格有多少行 多少列？
import React, { Component } from 'react';
import CommTable from './commTable';
export default class Worksheet extends Component {
    getCommTable(rowNum,colNum,reportId) {
        return <CommTable  rowNum={rowNum} colNum={colNum} reportId={reportId}  onRef={this.workTableRef}/>;
    }
    componentDidMount(){
        this.props.onRef(this)  //这个就是把自身传给调用者
    }
    workTableRef=(ref)=>{
        this.workTable = ref
    }


    //save Table
    saveTable=(report_id)=>{
        this.workTable.saveTable(report_id);
    }

//追加行
    appendRow=()=>{
        this.workTable.appendRow(-1);
    }
    insertRow=()=>{
        this.workTable.appendRow(-2);
    }
    deleteRow=()=>{
        this.workTable.appendRow(-3);
    }



    //追加列
    appendCol=()=>{
        this.workTable.addOrDelCol(-1);
    }
    insertCol=()=>{
        this.workTable.addOrDelCol(-2);
    }
    deleteCol=()=>{
        this.workTable.addOrDelCol(-3);
    }
    //align
    align=(d)=>{
        this.workTable.align(d);
    }
    //hiden data
    hidenData=(v)=>{
        this.workTable.hidenData(v);
    }

    isThousandsFormat=()=>{
        this.workTable.isThousandsFormat();
    }

    isPercentageFormat=()=>{
        this.workTable.isPercentageFormat();
    }

    setDecimalPlaces=(p)=>{
        this.workTable.setDecimalPlaces(p);
    }

    clearNumFormat=()=>{
        this.workTable.clearNumFormat();
    }




    editFont=(t)=>{
        this.workTable.editFont(t);
    }
    modifyBorderStyle=(t)=>{
        this.workTable.modifyBorderStyle(t);
    }
    mergeCells=()=>{
        this.workTable.mergeCells();
    }
    splitCells=()=>{
        this.workTable.splitCells();
    }

     saveFormulaToCell=(fomulaTxt)=>{
        this.workTable.saveFormulaToCell(fomulaTxt);
    }

    hasSelectedCell=()=>{
        return this.workTable.hasSelectedCell();
    }

    getSelectCellValue=()=>{
        return this.workTable.getSelectCellValue();
    }

    render() {
        let _reportId=this.props.reportId;
        return (
              <div className="worksheet">
                <div className="commTable">
                    {this.getCommTable(10,5,_reportId)}
                </div>
            </div>
        )
    }
}
